import { NEXT_STEP, PRE_STEP, CREATE_KMX_DATA, STORE_CM_DATA, GET_KMX_NAME } from './action'
import update from 'react-addons-update'
export default function stepReducer (state = {
  step: 1,
  kmxdata: {},
  cmData: {},
  kmxName: ''
}, action) {
  switch (action.type) {
    case NEXT_STEP:
      return update(state, {
        step: { $set: action.next }
      })
    case PRE_STEP:
      return update(state, {
        step: { $set: action.pre }
      })
    case CREATE_KMX_DATA:
      return update(state, {
        kmxdata: action.json
      })
    case STORE_CM_DATA:
      return update(state, {
        cmData: { $set: action.json }
      })
    case GET_KMX_NAME:
      return update(state, {
        kmxName: { $set: action.name }
      })
    default:
      return state
  }
}
